﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PhysicalExamination5.Model.SystemSetting
{
    public class QuanXianDataClass
    {
        public string strCode { get; set; }
        public string strName { get; set; }
        public List<ChildrenClass> children { get; set; }
    }
    public class ChildrenClass
    {
        public string strCode { get; set; }
        public string strName { get; set; }
    }

    public class JueSeClass
    {
        public string strJuSeId { get; set; }
        public string strJuSeName { get; set; }
        public int iShunXu { get; set; }
        public bool Validate(string strType,out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> missingKeys = new List<string>();
            switch (strType)
            {
                case "Add":
                    if (string.IsNullOrEmpty(strJuSeName))
                    {
                        missingKeys.Add("角色名称");
                    }
                    break;
                case "Update":
                    if (string.IsNullOrEmpty(strJuSeId))
                    {
                        missingKeys.Add("角色ID");
                    }
                    if (string.IsNullOrEmpty(strJuSeName))
                    {
                        missingKeys.Add("角色名称");
                    }
                    break;
                case "Delete":
                    if (string.IsNullOrEmpty(strJuSeId))
                    {
                        missingKeys.Add("角色ID");
                    }
                    break;
            }
            if (missingKeys.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", missingKeys) + "是必填项！";
            }
            return isSuccess;
        }
    }
    public class UserClass
    {
        public string strUserId { get; set; }
        public string strJueSeId { get; set; }
        [Required(ErrorMessage = "用户代码是必填项！")]
        public string struCode { get; set; }
        [Required(ErrorMessage ="用户名称是必填项！")]
        public string struName { get; set; }
        [Required(ErrorMessage = "拼音码是必填项！")]
        public string struPYM { get; set; }
        public string strShenFenZhengHao { get; set; }
        public string strZhiYeLeiBie { get; set; }
        public string strYaoShiZhiCheng { get; set; }
        public string strSuoShuKeShi { get; set; }
        public string strXueLi { get; set; }
        public string strShouJiHao { get; set; }
        public string strBeiZhu { get;set; }
        public string strShiFouZongJianYiShi { get; set; }
        public string strDianZiQianMing {  get; set; }
        public string strYongHuZuiDaZheKou {  get; set; }
        public bool Validate(string strType, out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            switch (strType)
            {
                case "Add":
                    if (string.IsNullOrEmpty(strUserId))
                    {
                        Message.Add("角色ID");
                    }
                    break;
                case "Update":
                    if (string.IsNullOrEmpty(strUserId))
                    {
                        Message.Add("用户ID");
                    }
                    break;
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message) + "是必填项！";
            }
            return isSuccess;
        }
    }
    public class YongHuClass
    {
        public string strJuseId {  get; set; }
        [Required(ErrorMessage = "用户代码是必填项！")]
        public string struCode { get; set;}
        public int iShunXu { get; set; }
    }
    public class SaveJuSeQuanXianClass
    {
        [Required(ErrorMessage = "类型是必填项！")]
        public string strType { get; set; }
        [Required(ErrorMessage = "角色ID是必填项！")]
        public string strJueSeId { get; set;}
        public List<string> listQuanXianId { get; set; }
        public bool Validate(out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            if (listQuanXianId == null || listQuanXianId.Count == 0)
            {
                strFanHuiZhi = "权限集合为空或没有数据！";
            }
            return isSuccess;
        }
    }
    public class UserQuanXianClass
    {
        [Required(ErrorMessage = "类型是必填项！")]
        public string strType { get; set; }

        public string strLeiBie { get; set; }
        public List<string> listUcode { get; set; }

        public List<string> listQuanXianId { get; set; }
        public bool Validate(out string strFanHuiZhi)
        {
            bool isSuccess = true;
            strFanHuiZhi = "";
            List<string> Message = new List<string>();
            if (listUcode == null || listUcode.Count == 0)
            {
                Message.Add("用户ID集合为空或没有数据！");
            }
            if (listQuanXianId == null || listQuanXianId.Count == 0)
            {
                Message.Add("权限集合为空或没有数据！");
            }
            if (Message.Count > 0)
            {
                isSuccess = false;
                strFanHuiZhi = string.Join("、", Message);
            }
            return isSuccess;
        }
    }
    public class UserJueSeShunXuClass
    {
        [Required(ErrorMessage = "类型是必填项！")]
        public string strType { get; set; }
        [Required(ErrorMessage = "角色代码是必填项！")]
        public string strJuseId { get; set; }
        [Required(ErrorMessage = "用户代码是必填项！")]
        public string strUserId { get; set; }
        public int iTiaoZhengQianShunXu { get; set; }
        public int iTiaoZhengHouShunXu { get; set; }
    }
}
